<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html >
<html>
	<head>
		<%@ include file="/common/taglibs.jsp"%>
		<title>sinlog</title>
	</head>
	<body>
	<div class="mainContent">
		<div class="searDiv">
			<table class="searTb">
				<tr>
					<td><table>
						<tr>
							<td width="100" align="right"><label>类型代码：</label></td>
							<td><input id="q_typeCode" type="text" /></td>
							<td width="100" align="right"><label>类型名称：</label></td>
							<td><input id="q_typeName" type="text" /></td>
						</tr>
					</table></td>
					<td width="200"><a href="javascript:doQuery();" class="button blue">查询</a></td>
				</tr>
			</table>
		</div>
		<div class="dgDiv">
			<table id="dg"></table> 
		</div>
	</div>
<script type="text/javascript">
	$(document).ready(function(){
		$('#dg').datagrid({   
		    url:'${ctx}/param!listParamType.action',   
		    pagination:true,
		    height: getDgH('dgDiv') - 55,
		    pageSize:30,
		    pageList:[30,60,100,200], 
		    columns:[[   
		        {checkbox:true,field:'ck'},
		        {title:'类型代码',field:'typeCode',width:200},
		        {title:'类型名称',field:'typeName',width:200},
		        {field:'editor',title:'操作',width:100,align:'center',formatter:function(value,row,index){
					var ed = '<a class="dicon icon-search" title="详细" onclick=goView(\''+row.typeId+'\')></a>&nbsp;';
					ed += '<a class="dicon icon-edit" title="修改" onclick=goEdit(\''+row.typeId+'\')></a>&nbsp;';
					ed += '<a class="dicon icon-gear" title="修改参数" onclick=goEditParam(\''+row.typeId+'\')></a>&nbsp;';
					ed += '<a class="dicon icon-remove" title="删除" onclick=goDelete('+null+',\''+row.typeId+'\')></a>';
					return ed;
				}}
		    ]],
		    toolbar:[{
		    	text:'新增',  
				iconCls: 'icon-add',
				handler: goAdd
			},{
		    	text:'删除',  
				iconCls: 'icon-remove',
				handler: goDelete
			},{
		    	text:'刷新缓存',  
				iconCls: 'icon-refresh',
				handler: goRefresh
			}],
		    queryParams:{
		       'q_typeCode_eq_s': $('#q_typeCode').val(),
		       'q_typeName_eq_s': $('#q_typeName').val()
		   	},
		   	onDblClickRow:function(rowIndex, rowData){
		   		goEdit(rowData.typeId);
		   	}
		}); 
	});
	function doQuery(){
		var queryParams = $('#dg').datagrid('options').queryParams;
	    queryParams["q_typeCode_eq_s"] = $('#q_typeCode').val();
	    queryParams["q_typeName_eq_s"] = $('#q_typeName').val();

	    $('#dg').datagrid('options').pageNumber = 1;
	    var p = $('#dg').datagrid('getPager');
	    if (p){
	        $(p).pagination({
	           pageNumber:1,
	           pageSize:30
	        });
	        queryParams["rows"] = 30;
	        queryParams["page"] = 1;
	    }
	    $('#dg').datagrid('reload');
	}
	function goAdd(){
		openMenu('参数管理-新增类型','${ctx}/param!add.action');
	}
	
	function goEdit(id){
		openMenu('参数管理-修改类型','${ctx}/param!edit.action?paramType.typeId='+id);
	}
	function goView(id){
		openMenu('参数管理-查看类型','${ctx}/param!view.action?paramType.typeId='+id);
	}
	function goEditParam(id){
		openMenu('参数管理-修改参数','${ctx}/param!goParam.action?paramType.typeId='+id);
	}
	function goDelete(event,id){
		var ids = '';
		if(id){
			ids = id;
		}else{
			var ids = getCkIds('dg','typeId');
		}
		if(ids == ''){
			$.messager.alert('系统提示','请选择要操作的记录！','info');
		}else{
			$.messager.confirm('系统提示','确定执行该操作？',function(r){
				if(r){
					wait();
					Util.doAjaxPost('${ctx}/param!delete.action',{ids:ids},function(text){
						uwait();
						var ret = jQuery.parseJSON(text);
						if(ret.success){
							doQuery();
						}else{
							$.messager.alert('系统提示','操作失败！','error');
						}
					});
				}
			});
		}
	}
	function goRefresh(){
		Util.doAjaxPost('${ctx}/param!refresh.action',null,function(text){
			var ret = jQuery.parseJSON(text);
			if(ret.success){
				$.messager.alert('系统提示','刷新成功！','info');
			}else{
				$.messager.alert('系统提示','操作失败！','error');
			}
		});
	}
</script>
	</body>
</html>